<template>
    <div>
        <Row>
            <Col span="12">
                <div style="background:#eee;padding: 20px">
                    <Card :bordered="false">
                        <div id="myChart" :style="{width: '300px', height: '300px'}"></div>
                    </Card>
                </div>
            </Col>
            <Col span="12">
                <div style="background:#eee;padding: 20px">
                    <Card :bordered="false">
                        <div id="myChart2" :style="{width: '300px', height: '300px'}"></div>
                    </Card>
                </div>
            </Col>
        </Row>

    </div>


</template>
<script>
    import echarts from 'echarts'
    Vue.prototype.$echarts = echarts;
    export default {
        name: "DashComponent",
        data() {
            return {}
        },
        mounted() {
            this.drawLine();
        },
        methods: {
            drawLine() {
                // 基于准备好的dom，初始化echarts实例
                let myChart = this.$echarts.init(document.getElementById('myChart'))
                // 绘制图表
                myChart.setOption({
                    title: {text: '最近浏览人数'},
                    tooltip: {},
                    xAxis: {
                        data: ["周一", "周二", "周三", "周四", "周五", "周六"]
                    },
                    yAxis: {},
                    series: [{
                        name: '人数',
                        type: 'bar',
                        data: [5, 20, 36, 10, 10, 20]
                    }]
                });

                //
                let line = this.$echarts.init(document.getElementById('myChart2'))
                line.setOption({
                    title: {text: '最近浏览人数曲线变化'},
                    tooltip: {},
                    xAxis: {
                        type: 'category',
                        data: ["周一", "周二", "周三", "周四", "周五", "周六"]
                    },
                    yAxis: {
                        type: 'value'
                    },
                    series: [{
                        name: '人数',
                        data: [5, 20, 36, 10, 10, 20],
                        type: 'line'
                    }]
                });

            }
        }
    }
</script>


